package org.han;

import org.han.interceptor.LoginInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 启动类111
 */
@SpringBootApplication
@MapperScan("org.han.*.mapper")
@ServletComponentScan("org.han.listener") //扫描监听器
public class PermissionApplicationStarter implements WebMvcConfigurer {
    public static void main(String[] args) {
        SpringApplication.run(PermissionApplicationStarter.class, args);
    }

    @Autowired
    private LoginInterceptor loginInterceptor;
    /**
     * 拦截器
     * @param registry
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginInterceptor).addPathPatterns("/**").excludePathPatterns("/login","/logout");
    }
}
